/**
* @file prs_bmp280.h in InsCubeBsp
* @author linfe
* @comment
* Create on 2022/11/29 23:45
* @version 1.0
**/

#ifndef INSCUBEBSP_CORE_SRC_DRIVERS_PRS_BMP280_H_
#define INSCUBEBSP_CORE_SRC_DRIVERS_PRS_BMP280_H_
#include "bsp.h"
typedef struct {
  uint16_t dig_T1;
  int16_t dig_T2;
  int16_t dig_T3;

  uint16_t dig_P1;
  int16_t dig_P2;
  int16_t dig_P3;
  int16_t dig_P4;
  int16_t dig_P5;
  int16_t dig_P6;
  int16_t dig_P7;
  int16_t dig_P8;
  int16_t dig_P9;
  int16_t reserved;
} bmp280_coefficients_t;
typedef struct {
  uint32_t baro_press;
  uint32_t temperature;
  float press_height;
} press_data_t;

typedef struct {
  bsp_device_t *dev;
  void (*delay_ms)(uint32_t ms);                /* 延时函数,单位ms*/
  int (*trace)(const char *fmt, ...);           /* 打印函数*/
  bmp280_coefficients_t coeff;
} bmp280_handle_t;

typedef enum {
  bmp280_ok = 0,
  bmp280_error_id = 1,
} bmp280_error_t;

bmp280_error_t bmp280_init(bmp280_handle_t *dev);

bmp280_error_t bmp280_read(bmp280_handle_t *dev, press_data_t *data);

#endif //INSCUBEBSP_CORE_SRC_DRIVERS_PRS_BMP280_H_
